home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++,comp.lang.java
- Path: uu4news.netcom.com!friend!news
- From: rich@kastle.com (Richard Krehbiel)
- Subject: Re: Java: What's the Big Deal?
- Message-ID: <1996Mar25.131115.29988@friend.kastle.com>
- Sender: news@friend.kastle.com (News)
- Reply-To: rich@kastle.com
- Organization: Kastle Development Associates
- X-Newsreader: Forte Free Agent 1.0.82
- References: <milodDoF9JF.K32@netcom.com> <1996Mar20.154600.12011@amc.com> <4iuenj$ng2@decaxp.HARVARD.EDU> <4iuo1r$e46@kai.com>
- Date: Mon, 25 Mar 1996 13:09:52 GMT
-
- robison@kai.com (Arch Robison) wrote:
-
- >Some people wrote:
- >>
- >>: : >>2) No header files => faster compilation
- >>: :
- >>: : >Nonsense. Header files are simply text that gets included where you want it. If
- >>: : >you write the same code without header files it will not magically compile
- >>: : >faster.
-
- Well... It may, and you may or may not notice the difference. Each
- #include causes the OS to perform a file system operation to locate
- the header file. If you in-line all the header files these lookups
- are not done.
-
- Usually the trick for omitting inclusion of a file that's already
- included is to put:
-
- #ifndef HEADER_H
- #define HEADER_H
- /* text of header.h */
- #endif
-
- ...inside the header file, and I consider this the best way because it
- conveniently centralizes the management and reduces the possibility of
- errors in programs that include this header. However, a performance
- enhancement I used on my old floppy-disk-based Amiga compiler setup
- was this instead:
-
- #ifndef HEADER_H
- #define HEADER_H
- #include "header.h"
- #endif
-
- The speedup is because now there is no need for the compiler to open
- header.h and read all of it's contents to find that it has been
- totally conditionalized away. On track-buffered floppy disks this was
- so much faster as to be worth the effort to remember to type the
- incant for each inlcusion (and retype and recompile for each time I
- forgot it/botched it).
-
- >If header files don't slow down compilation, why do so many C/C++
- >compilers offer a "precompiled header" feature to make compilation faster?
-
- It's not because headers in particular are slow, but because
- *compiling* is slow, when compared with *not* compiling. "make" and
- Makefiles serve the same purpose, trying not to compile when it can be
- known it's not necessary.
-
- --
- Richard Krehbiel, Kastle Systems, Arlington VA USA
- rich@kastle.com (work) or richk@mnsinc.com (personal)
-
-